import java.util.Random;

/**
 * 测试崩坏3的低保机制
 * Created by qezhhnjy on 2017/10/20-12:46.
 */
public class Beng3 {

    public static void main(String[] args) {
        int sa = 0;
        int sb = 0;
        for (int j = 0; j < 100; j++) {
            int result = 0;
            Random r = new Random();
            //假设官方概率为13%,10次保底,则10次期望是1.3,减去保底为0.3.即保底前出货概率为1/30(1/30*9=30%),出货即重置保底.
            for (int i = 0; i < 10000; i++) {
                int temp = r.nextInt(100);
                if (temp <= 12) result++;
            }
            System.out.println(result);
            sa += result;
            int[] a = new int[9];
            int result2 = 0;
            for (int i = 0; i < 10000; i++) {
                if (hasPink(a) == -1 || hasPink(a) == 0) {
                    int i1 = r.nextInt(30);
                    if (i1 <= 0) {
                        result2++;
                        arrays(a, -1);
                    } else {
                        arrays(a, 1);
                    }
                } else if (hasPink(a) == 1) {
                    result2++;
                    arrays(a, -1);
                }
            }
            System.out.println(result2);
            sb += result2;
            System.out.println("-----分割线-----");
        }
        System.out.println(sa);
        System.out.println(sb);
    }

    public static int hasPink(int[] a) {
        for (int i : a) {
            if (i == -1) return -1;
        }
        if (a[a.length - 1] == 1) return 1;
        return 0;
    }

    //出货-1,不出1,默认为0
    public static void arrays(int[] a, int b) {
        for (int i : a) {
            if (i == 0) {
                i = b;
            }
        }
        System.arraycopy(a, 1, a, 0, a.length - 1);
        a[a.length - 1] = b;
    }
}
